﻿Imports System.Data.OleDb

Public Class AddLocation
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If f_picture.HasFile Then
            f_picture.SaveAs(Request.MapPath("Pictures") & "/" & f_picture.FileName)
        End If

        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("HauntedLocationString").ConnectionString)
        Dim SqlString As String = "Insert Into HauntedLocations(LocationName, Type, Address, City, State, Zipcode, Coutry, Picture, Website, Description) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8,@f9,@f10)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, conn)
        cmd.CommandType = CommandType.Text
        conn.Open()
        cmd.Parameters.AddWithValue("@f1", tb_locationname.Text)
        cmd.Parameters.AddWithValue("@f2", tb_type.Text)
        cmd.Parameters.AddWithValue("@f3", tb_address.Text)
        cmd.Parameters.AddWithValue("@f4", tb_city.Text)
        cmd.Parameters.AddWithValue("@f5", tb_state.Text)
        cmd.Parameters.AddWithValue("@f6", tb_zipcode.Text)
        cmd.Parameters.AddWithValue("@f7", tb_country.Text)
        cmd.Parameters.AddWithValue("@f8", "Pictures/" & f_picture.FileName)
        cmd.Parameters.AddWithValue("@f9", tb_website.Text)
        cmd.Parameters.AddWithValue("@f10", tb_description.Text)
        cmd.ExecuteNonQuery()
        conn.Close()

        Response.Redirect("Confirmation.aspx")

    End Sub
End Class